//
//  KHFrameAdaptiveClass.m
//  kehou_netstudy
//
//  Created by lichengfu on 2018/5/3.
//  Copyright © 2018年 浙江万朋教育科技股份有限公司. All rights reserved.
//

#import "KHFrameAdaptiveClass.h"

#define KScreenHeight [UIScreen mainScreen].bounds.size.height
#define IPHONE5S KScreenHeight == 568.0
#define IPHONE6S KScreenHeight == 667.0
#define IPHONE6SP KScreenHeight == 736.0
#define IPHONEX KScreenHeight >= 812.0

@implementation KHFrameAdaptiveClass

+ (CGFloat)adaptiveSizeWithPt:(CGFloat)pt
{
     if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
         NSArray<NSString *> *symbols = [NSThread callStackSymbols];
         for (NSString *symbol in symbols) {
             if ([symbol containsString:@"-[KHEmptyView initializeUI]"]) {
                 return round(pt * 1.3);
             }
         }
    }
    if (IPHONE6S) {             /// 6 6S 7 7S
        return round(pt);
    } else if (IPHONE5S) {      /// 5s
        return round(pt * 320 / 375);
    } else if (IPHONE6SP) {     /// P
        return round(pt * 414 / 375);
    } else {                    /// X
        return round(pt);
    }
}
+ (CGFloat)adaptiveHeightWithPt:(CGFloat)pt
{
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
        NSArray<NSString *> *symbols = [NSThread callStackSymbols];
        for (NSString *symbol in symbols) {
            if ([symbol containsString:@"-[KHEmptyView initializeUI]"]) {
                return round(pt * 1.3);
            }
        }
    }
    if (IPHONE6S) {             /// 6 6S 7 7S
        return round(pt);
    } else if (IPHONE5S) {      /// 5s
        return round(pt * 568 / 667);
    } else if (IPHONE6SP) {     /// P
        return round(pt * 736 / 667);
    } else if (IPHONEX){                    /// X
        return round(pt * 812 / 667);
    } else {
        return round(pt);
    }
}
+ (CGFloat)adaptiveFontWithPt:(CGFloat)pt
{
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
        NSArray<NSString *> *symbols = [NSThread callStackSymbols];
        for (NSString *symbol in symbols) {
            if ([symbol containsString:@"-[KHEmptyView initializeUI]"]) {
                return round(pt * 1.3);
            }
        }
    }
    return pt;
//    if (IPHONE6S) {             /// 6 6S 7 7S
//        return pt;
//    } else if (IPHONE5S) {      /// 5s
//        return pt * 320 / 375;
//    } else if (IPHONE6SP) {     /// P
//        return pt * 414 / 375;
//    } else {                    /// X
//        return pt;
//    }
}
@end
